package cn.rongdao.jrkabao.ui;

import android.content.Context;

import com.mifengkong.frtools.ui.activity.FRStartActivity;
import com.mifengkong.frtools.util.FRToast;

import butterknife.OnClick;
import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.base.BaseAutoFinishActivity;
import cn.rongdao.jrkabao.model.main.tab.TabModel;
import cn.rongdao.jrkabao.ui.login.LoginActivity;
import cn.rongdao.jrkabao.ui.main.MainActivity;
import cn.rongdao.jrkabao.util.LoginUtil;

/**
 * Created by jack on 2018/4/23
 */

public class NoNetWorkActivity extends BaseAutoFinishActivity {

    public static void start(Context context) {
        FRStartActivity.start(context, NoNetWorkActivity.class);
    }

    @Override
    protected int layoutRes() {
        return R.layout.activity_no_network;
    }

    @Override
    protected void initView() {
        super.initView();
        TabModel.getInstance().setOnTabRequestListener(new TabModel.OnTabRequestListener() {
            @Override
            public void success() {
                if (LoginUtil.isLogin()) {
                    if (LoginUtil.isLogin()) {
                        MainActivity.Companion.start(thisActivity());
                    } else {
                        LoginActivity.start(thisActivity());
                    }
                    finish();
                }
            }

            @Override
            public void failure(Throwable t) {
                FRToast.showToastSafe("请检查当前网络是否可用");
            }
        });
    }

    @OnClick(R.id.ann_tv_refresh)
    public void onViewClicked() {
        TabModel.getInstance().setTab();
    }
}
